package cn.edu.sgu.www.mhxysy.controller.equipment;

import cn.edu.sgu.www.mhxysy.vo.Imager;
import cn.edu.sgu.www.mhxysy.consts.CustomConstants;
import cn.edu.sgu.www.mhxysy.consts.CustomMessages;
import cn.edu.sgu.www.mhxysy.consts.MimeTypes;
import cn.edu.sgu.www.mhxysy.entity.equipment.EquipmentType;
import cn.edu.sgu.www.mhxysy.restful.JsonResult;
import cn.edu.sgu.www.mhxysy.service.equipment.EquipmentTypeService;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * @author 沐雨橙风ιε
 * @version 1.0
 */
@Api(tags = "装备类型管理")
@ApiSupport(author = CustomConstants.AUTHOR)
@Validated
@RestController
@RequestMapping(path = "/equipment_type", produces = MimeTypes.APPLICATION_JSON_CHARSET_UTF_8)
public class EquipmentTypeController {

	private final EquipmentTypeService equipmentTypeService;

	@Autowired
	public EquipmentTypeController(EquipmentTypeService equipmentTypeService) {
		this.equipmentTypeService = equipmentTypeService;
	}

	@ApiOperation("通过ID查询顶级装备类型信息")
	@RequestMapping(value = "/selectTop", method = RequestMethod.GET)
	public JsonResult<Imager> selectTop(
			@ApiParam(name = "id", value = "装备类型ID", required = true)
			@NotNull(message = CustomMessages.ID_NOT_NULL) Integer id) {
		Imager imager = equipmentTypeService.selectTop(id);

		return JsonResult.success(null, imager);
	}

	@ApiOperation("查询顶级装备类型")
	@RequestMapping(value = "/selectParent", method = RequestMethod.GET)
	public JsonResult<List<Imager>> selectParent() {
		List<Imager> list = equipmentTypeService.selectParent();

		return JsonResult.success(null, list);
	}

	@ApiOperation("查询全部装备类型")
	@RequestMapping(value = "/selectAll", method = RequestMethod.GET)
	public JsonResult<List<Imager>> selectAll() {
		List<Imager> list = equipmentTypeService.selectAll();

		return JsonResult.success(null, list);
	}

	@ApiOperation("查询全部一级装备类型")
	@RequestMapping(value = "/selectTypes", method = RequestMethod.GET)
	public JsonResult<List<Imager>> selectTypes() {
		List<Imager> list = equipmentTypeService.selectTypes();

		return JsonResult.success(null, list);
	}

	@ApiOperation("查询全部武器类型")
	@RequestMapping(value = "/selectWeaponry", method = RequestMethod.GET)
	public JsonResult<List<Imager>> selectWeaponry() {
		List<Imager> list = equipmentTypeService.selectWeaponry();

		return JsonResult.success(null, list);
	}

	@ApiOperation("通过装备类型查询装备类型信息")
	@RequestMapping(value = "/selectType", method = RequestMethod.GET)
	public JsonResult<Imager> selectType(
			@ApiParam(name = "id", value = "装备类型", required = true)
			@NotNull(message = "装备类型" + CustomMessages.NOT_NULL) Integer type) {
		Imager imager = equipmentTypeService.selectType(type);

		return JsonResult.success(null, imager);
	}

	@ApiOperation("通过ID查询装备类型信息")
	@RequestMapping(value = "/selectById", method = RequestMethod.GET)
	public JsonResult<EquipmentType> selectById(
			@ApiParam(name = "id", value = "装备类型ID", required = true)
			@NotNull(message = CustomMessages.ID_NOT_NULL) Integer id) {
		EquipmentType equipmentType = equipmentTypeService.selectById(id);

		return JsonResult.success(null, equipmentType);
	}

}